/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.yxw.yxnet_cd_center.common.utils;

import lombok.extern.slf4j.Slf4j;

/**
 * @author admin
 */

@Slf4j
public class RSAKeyUtil {
    public static final String CHARSET = "UTF-8";
    public static final String RSA_ALGORITHM = "RSA"; // ALGORITHM 算法的意思  RSA   RSA/None/PKCS1Padding
//    public static final String PublicKeyStr = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDPuYdrnfdtY_qh-QaM_9GbypSPVfR-Th7xKZoLOw1OhDOM2J4UyQv41ZsMhEJvbTCKDhdAWhwDg6fPQr5jJ9zScafQAtNuLn-NBaR2Aoxc7rUc0IfLfBKbXhBg-pj16l94eocnPRI3FoS21ggi1XWwzqRX46NGMuQmeuktI6adbwIDAQAB";
//    public static final String PrivateKeyStr ="MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAM-5h2ud921j-qH5Boz_0ZvKlI9V9H5OHvEpmgs7DU6EM4zYnhTJC_jVmwyEQm9tMIoOF0BaHAODp89CvmMn3NJxp9AC024uf40FpHYCjFzutRzQh8t8EpteEGD6mPXqX3h6hyc9EjcWhLbWCCLVdbDOpFfjo0Yy5CZ66S0jpp1vAgMBAAECgYEAii2FGp5S985464PmyqZlfXetiQeJgvded9fPo8bdXCxuyjNSPMtcDmOxJwtX0h1VG5CyANmwJtpOJ33jfbwHlDWgnYRG8Zdk7o_DLEaecK51XMWDlBh2ful7BzyqTCkxzMS4BlT0x4qKknjy4YPEWUMCOEDPEBFP1N-KGl_91JECQQD7NkG05VPjl0hCqF1sEyxSoFYwfOOcOv6GIavG-KQ59AeT6AM_2V-VnM4uz6ynkovvujIiinJC1CDpSg0yGey3AkEA068Vk-sk1M7IitAB0QVvRdvg4vLifsPPLi8lPuRVExRNnI_v5AwQKC6BNHOZIgIwuwbO7WItvVa9bqELpggNCQJACtr9W-PNDDitVrQP1Wu-rpNfJhk_fLDP7tvloGN-NULmUO3ltgyepMhx4HP48gTTJzjUkcmJxnmEMpCQoWmdYQJAZ5_j_j80DoETpvBgk0QHzrjug-rGeau9NiyaHQmFpAtiWuwTUR2eoyzwzw5vvjg4RrX0gjx3i6J0pT1tCGAUkQJBAIQzOzxTk_risPt6ISP9POn9QqIYodKzmRzgTNQJ6a_OOZFnFh3HrM3Xaf6law8z8JFOrGNwwqFeNp_OA3udeTQ";

    public static final String PublicKeyStr = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDXwnrkylXMTprBjILQMUbdHNCPWK0qi52BGe8JWag+sEAlL0fRjPNrGnQZnSyYx3eEIT3o0upyk/G69EmpIFFgpWgJeKuEDwp76afywyk8+LQTw96g7yn+E0VbZdcUqnwDxpVur4TW1g4OJ6V47h0nyflDeNOtSCzvE58BAaWiEwIDAQAB";
    public static final String PrivateKeyStr = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANfCeuTKVcxOmsGMgtAxRt0c0I9YrSqLnYEZ7wlZqD6wQCUvR9GM82sadBmdLJjHd4QhPejS6nKT8br0SakgUWClaAl4q4QPCnvpp/LDKTz4tBPD3qDvKf4TRVtl1xSqfAPGlW6vhNbWDg4npXjuHSfJ+UN4061ILO8TnwEBpaITAgMBAAECgYBYd63cUfqMI07hPbQFma7syvvZSwr1/vk+DlwtAU4zJiGnHZPdIGZO7DHersuyeVdQHjE8Xf8zq+XaOoBZkJ7MuTlcjrs2twCXO0pwfXdbsyjKPzP6O/0OnlQ+Rp3cPNuxtmIi6qFqV0qQALDHa5hUgidIijshnXNscATRBEXbwQJBAPE/OijfUCuMTCBvHoqbusMolzKpe0zkVYFkrDZgUJ3DQAG8zEVZPniLhjYe0d969FKR5TFItFL8lAIEO+tP+t0CQQDk9D5t+vIYd7mx4oUJTVN3bS2vyTcpyS10DRKdx/taw8DG3gh+tOJJCb1qAvSGNuRVYGg/u/DfphZKrSCb3umvAkEAvQb0tEfeEnE4yQUoYiUJnpc0eY7QvPwAf4V5ZpXrNOJjSbk8OW5nA58Xh1p4yeoWfIgylH5KROgBtN7KcGPXxQJAPKBYb7MFrGj3qRz8cWwib/tfH68+hjgZayOTDGjKLEytnXtp8HNhgEmt+IZzzZ53dAwlTssri21ldbzGZ7/tTQJAKDMLxgTWOdPnSmYcnziDaNXZobxYbc/M08C9gsx8YoTKOw6oob9ABkmWMcd2IvBsHQIUPtwlePc8hTk4qhp1ew==";

    public static void main(String[] args) throws Exception {
        String password = "123456";
        String passwordMd5 = PasswordUtil.md5Hex(password);
        System.out.println("passwordMd5:" + passwordMd5);
        String publicEncrypt = RSAUtil.publicEncrypt(passwordMd5, RSAUtil.getPublicKey(RSAKeyUtil.PublicKeyStr));
        System.out.println("publicEncrypt:" + publicEncrypt);
        String privateDecrypt = RSAUtil.privateDecrypt(publicEncrypt, RSAUtil.getPrivateKey(RSAKeyUtil.PrivateKeyStr));
        System.out.println("privateDecrypt:" + privateDecrypt);

    }
}